import java.util.concurrent.*;

public class NewThreadWorker {

    public NewThreadWorker(String name){
        ThreadFactory threadFactory = new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
                return new Thread(r, name + System.currentTimeMillis());
            }
        };
        executor = Executors.newSingleThreadExecutor(threadFactory);
    }

    private ExecutorService executor;

    public void schedule(Runnable runnable) {
        executor.execute(runnable);
    }

    public void finish() {
        executor.shutdown();
    }
}
